<template>
	<view>
		<view class="header">个人状况</view>

		<view class="content">
			<view class="title">备注:</view>
			<textarea class="text_remark" auto-height maxlength="-1" v-model="info.remark"/>
		</view>
		<button @click="addStatus" class="buttonClass">提交</button>
	</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			member_id:0,
			info:{
				remark:''
			},
		}
	},
	onLoad:function(e){
		uni.showLoading({
			title:'加载中.'
		})
		this.member_id = e.id
		this.getInfo()
	},
	methods: {
		getInfo:function(){
			var data = {member_id:this.member_id}
			var that = this
			request({
				url: 'manage/status/info',
				method: 'get',
				data:data,
				success: (res) => {
					uni.hideLoading()
					if(res.data.data){
						that.info = res.data.data
					}
				},
			})
		},
		addStatus:function(){
			if(!this.info.remark){
				uni.showToast({
					title: '请输入备注!!!',
					icon: "none", 
					position:'bottom',
				});
				return;
			}
			this.info.oa_id = uni.getStorageSync('oa_id')
			this.info.user_id = uni.getStorageSync('uid')
			this.info.member_id = this.member_id
			var that = this
			var pages = getCurrentPages();
			var currPage = pages[pages.length - 1]; //当前页面
			var prevPage = pages[pages.length - 2]; //上一个页面
			request({
				url: 'manage/status/add',
				method: 'post',
				data:this.info,
				success: (res) => {
					if(res.data.code == 1){
						if(prevPage.route == 'manage/member/file'){
							prevPage.$vm.item.remark = that.info.remark
						}
						uni.showToast({
							title:'提交成功',
							icon: 'none',
							duration: 2000,
							success() {
								setTimeout(function(){
									uni.navigateBack()
								}, 2000);
							}
						})
					}else{
						uni.showToast({
							title:'提交失败',
							icon: 'none',
							duration: 2000,
						})
						return;
					}
				},
			})
		},
		close:function(data){
			this[data.model] = false
			if(data.type){
				uni.showLoading()
				this.getList();
			}
		}
	},
}
</script>
<style>
@import url("../css/member/status.css");
</style>